package com.android.lovingpet;

import android.content.Context;
import android.graphics.BitmapFactory;

import com.android.lovingpet.util.ImageUtil;
import com.android.lovingpet.util.LocationClient;
import com.android.lovingpet.util.Utility;
import com.tencent.bugly.crashreport.CrashReport;

import org.litepal.LitePal;
import org.litepal.LitePalApplication;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;

/**
 * Created by ikata on 2018/2/27.
 */

public class Application extends android.app.Application {

    private static Context context;

    @Override
    public void onCreate() {
        super.onCreate();
        LitePal.initialize(this);
        context = getApplicationContext();
        //bugly
        CrashReport.initCrashReport(getApplicationContext(), "07e1232bf4", true);


        File file = new File(Application.getContext().getFilesDir() + File.separator + "defaultFace.jpg");
        if (!file.exists()) {
            FileOutputStream fos = null;
            try {
                fos = openFileOutput("defaultFace.jpg", Context.MODE_PRIVATE);
                fos.write(ImageUtil.toBytes(BitmapFactory.decodeResource(getResources(), R.drawable.defaultface)));
                fos.flush();
            } catch (IOException e) {
                e.printStackTrace();
            } finally {
                try {
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static Context getContext() {
        return context;
    }



}
